//
//  ConfirmArtTicketRequest.m
//  EasyToo
//
//  Created by zhengzhe on 13-8-25.
//
//

#import "ConfirmArtTicketRequest.h"

@implementation ConfirmArtTicketRequest

- (id)confirmBuyArtTicket:(id<ServerCommunicationDelegate>)delegate
             agentOrderID:(NSString*)agentOrderID
                   amount:(NSString*)amount
              projectName:(NSString*)projectName
                    phone:(NSString*)phone
                 allPrice:(int)allPrice
{
    self = [super init];
    if (self) {
        self.requestName = @"ConfirmArtTicketRequest";
        self.delegate = delegate;
        
        self.url = PROTOCOL_ORDER_URL;
        
        [self.bodyJsonDict setObject:agentOrderID forKey:@"agentOrderID"];
        [self.bodyJsonDict setObject:amount forKey:@"amount"];
        [self.bodyJsonDict setObject:[self URLEncodedString:projectName] forKey:@"projectName"];
        [self.bodyJsonDict setObject:phone forKey:@"phone"];
        
        [self.headerJsonDict setObject:@"004005" forKey:@"TranCode"];
        
        //银联支付价格
        [self.headerJsonDict setObject:[NSString stringWithFormat:@"%d", allPrice*100] forKey:@"TxAmt"];

        [self buildJsonRequest];
    }
    return self;
}


- (NSString*)URLEncodedString:(NSString*)input
{
    NSString *result = (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
                                                                           (CFStringRef)input,
                                                                           NULL,
                                                                           CFSTR("!*'();:@&=+$,/?%#[]"),
                                                                           kCFStringEncodingUTF8);
    [result autorelease];
    return result;
}

@end
